<template>
	<view>
		<cEditor :htmlContent="htmlContent" ref="cEditor" :uploadUrl="uploadUrl" :header="header"
			:isUseCustomNavbar="isUseCustomNavbar" @uploadFile="uploadFile" @saveContent="saveContent"></cEditor>
	</view>
</template>

<script>
	import cEditor from "@/components/editor.vue"
	export default {
		components: {
			cEditor
		},
		data() {
			return {
				/* 图片上传路径 */
				uploadUrl: "https://afyc.chitong.cn/api/public/images/upload",
				htmlContent: '',
				/* 是否使用自定义导航栏 */
				isUseCustomNavbar: true,
			}
		},
		onLoad() {
		},
		methods: {
			saveContent(data) {
				uni.$emit("getEdit", {
					detail: data.htmlContent,
					detailText: data.content
				})
				uni.navigateBack()

			},
			uploadFile(fileUrl) {
				/* 此处为你上传图片服务器后得到的url链接 */
				console.log(fileUrl, 'urlPathurlPathurlPathurlPath');
				var urlPath = JSON.parse(fileUrl.data).data;
				this.$refs.cEditor.editorCtx.insertImage({
					src: 'https://afyc.chitong.cn/uploads/' + urlPath
				})
			},
		}
	}
</script>

<style>
</style>